#ifndef USERS_REGISTER_HPP
#define USERS_REGISTER_HPP

#include "tools/ReadAndWeite.hpp"
#include <map>
#include <ostream>
#include <string>
#include <vector>

namespace managerSystem {
class user {
public:
  user(const std::string &user_id);
  user(const std::string &user_name, const std::string &user_phone,
       const std::string &user_password, const std::string &user_email,
       const std::string &user_province, const std::string &user_points,
       const std::string &user_wants_major);
  friend std::ostream &operator<<(std::ostream &os, const user &u);

  // get 方法
  std::string get_user_id() const { return user_id_; }
  std::string get_user_name() const { return user_name_; }
  std::string get_user_phone() const { return user_phone_; }
  std::string get_user_password() const { return user_password_; }
  std::string get_user_email() const { return user_email_; }
  std::string get_user_province() const { return user_province_; }
  std::string get_user_points() const { return user_points_; }
  std::string get_user_wants_major() const { return user_wants_major_; }
  std::string get_user_status() const { return user_status_; }

private:
  nlohmann::json user_json_;
  std::string user_id_;
  std::string user_name_;
  std::string user_phone_;
  std::string user_password_;
  std::string user_email_;
  std::string user_province_;
  std::string user_points_;
  std::string user_wants_major_;
  std::string user_status_;
};

class usersManager {
public:
  usersManager();
  std::string usersRegister(const std::string &user_name,
                            const std::string &user_phone,
                            const std::string &user_password,
                            const std::string &user_email,
                            const std::string &user_province,
                            const std::string &user_points,
                            const std::string &user_wants_major);
  std::string usersDelete(const std::string &user_id,
                          const std::string &user_password);

  // 通过用户名查找用户ID
  std::string getUserIdByName(const std::string &user_name);

  // 通过用户ID查找用户名
  std::string getUserNameById(const std::string &user_id);

private:
  nlohmann::json users;
  std::vector<long long> user_ids_lists_;
  std::map<std::string, std::string>
      user_id_name_map_; // 用户ID与用户名的映射关系
};
} // namespace managerSystem

#endif // USERS_REGISTER_HPP